package cn.imnaer.service.rpc.userinfo.dao;

import org.bson.BSONObject;
import org.bson.util.JSON;

import cn.imnaer.database.BaseDao;
import cn.imnaer.database.define.DBConstant;

public class PublishLogDaoImpl extends BaseDao<Object> {
	private static  PublishLogDaoImpl instance=new PublishLogDaoImpl();
	
	private   PublishLogDaoImpl() {
		
	}
public static  PublishLogDaoImpl  geInstance(){
	return  instance;
}
	@Override
	protected String getDbSpaceName() {
		return DBConstant.SPACE.USER_INFO_SPACE;
	}

	@Override
	protected String getDbCollectionName() {

		return DBConstant.COLLECTION.PUBLISH_LOG_INFO_COLLECTION;
	}

    @Override
    protected String getPrimaryKey() {
        return null;
    }

	@SuppressWarnings("unchecked")
	public void insert(String jsonData) {
		BSONObject data = (BSONObject) JSON.parse(jsonData);
		this.insert(data, false);
	}
	public boolean find(String jsonData) {
		BSONObject matcher = (BSONObject) JSON.parse(jsonData);
		Object result = this.findOne(matcher);
		if (result != null) {
			return true;
		} else {
			return false;
		}
	}
	public void delete(String jsonData) {
		BSONObject matcher = (BSONObject) JSON.parse(jsonData);
	     this.delete(matcher );
	}
}
